package services;

import dao.IUsers;
import dao.UsersDaoimpl;
import factory.UsersDaoFactory;
import vo.Users;

import java.util.List;

public class UsersServicempl implements ICustomService{
    IUsers iUsers = UsersDaoFactory.getInstance();//获取对应的(客户操作类)接口对象,向上转型
    @Override
    public boolean add(Users users) {
        return iUsers.add(users);
    }

    @Override
    public boolean delete(Users users) {
        return iUsers.delete(users);
    }

    @Override
    public boolean modify(Users users) {
        return iUsers.modify(users);
    }

    @Override
    public Users getcustombyid(String name) {
        return iUsers.getcustombyid(name);
    }

    @Override
    public List<Users> getall() {
        return iUsers.getall();
    }
    public boolean isValid(String username, String password) { //判断客户账号是否合法
        IUsers iUser= UsersDaoFactory.getInstance();//获取对其实现操作的具体类
        Users users=iUser.getuser(username,password);//连接数据库,并且查询账户信息是否存在
        return users!=null?true:false; //不为空则代表查到了用户合法,反之非法

    }
}
